% ECG_TIMELINE      Function of plotting HR-real against time
%
% 1. plotting HR_real vs time
% 2. histogram of time
%
% See also: ecg_history, tsmovavg, ylim
% Copyright: Group 8
% Modified at 20th Oct 2010
%-------------------------------------------------------------------------
function ecg_timeline(HR_real)
%% Function of plotting HR-real against time
% 1. plotting HR_real vs time
% 2. histogram of time


 %% Find necessary variables
[max_HR,min_HR,sd_ecg,HR_modified] = ecg_history(HR_real);
 
 %% HR-beat number graph
    lag = 7;
    if length(HR_modified) <= lag
    warning('heartrate absent');
    return
    end
    
    running_average = tsmovavg(HR_modified, 's', lag);
    N = (1:length(HR_modified))+4;
    plot(N,HR_modified,'c',...
         N-(lag-1)/2,running_average,'b','linewidth',2);
    xlim([min(N) max(N)]);
    if(max_HR - min_HR < 4)
        ylim([min_HR-1 max_HR+1]);
    end
    
    title('Heart Rate'),xlabel('Beat number'),ylabel('heart rate / min^{-1}');